//80. 删除有序数组中的重复项 II
//思路：双指针的快慢指针解法

#include <vector>
using namespace std;

class Solution {
public:
    int removeDuplicates(vector<int>& nums) 
    {
        int n = nums.size();
        if(n <= 2) return n;//特殊情况处理

        int fast = 2, slow = 2;
        while(fast < n)
        {
            if(nums[fast] != nums[slow-2])
            {
                nums[slow] = nums[fast];
                slow++;
            }
            fast++;
        }
        return slow;
    }
};